package com.blog.service.Impl;

import com.blog.dao.FavoriteMapper;
import com.blog.pojo.Blog;
import com.blog.pojo.Favorite;
import com.blog.pojo.ThumbsUp;
import com.blog.service.FavoriteService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Copyright (C), 2022
 * Author: 苏大大
 * Date: 2022-06-09 17:07
 * FileName: FavoriteServiceImpl
 * Description: 收藏业务层实现
 */
@Service
public class FavoriteServiceImpl implements FavoriteService {
    @Resource
    private FavoriteMapper favoriteMapper;

    @Override
    public int deleteFavorite(Long blogId, Long uid) {
        return favoriteMapper.deleteFavorite(blogId, uid);
    }

    @Override
    public int insetFavorite(Favorite favorite) {
        return favoriteMapper.insert(favorite);
    }

    @Override
    public Favorite selectFavorite(Long blogId, Long uid) {
        return favoriteMapper.selectFavorite(blogId, uid);
    }

    @Override
    public List<Blog> queryFavoriteBlogs(Long uid,String title) {
        return favoriteMapper.queryFavoriteBlogs(uid,title);
    }

    @Override
    public PageInfo<Blog> queryFavoriteBlogsPage(int pageNumber, int pageSize, Long uid, String title) {
        PageHelper.startPage(pageNumber,pageSize);
        List<Blog>list= favoriteMapper.queryFavoriteBlogs(uid,title);
        PageInfo<Blog> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }
}
